#pragma once
#include <vector>

void SelectSort(std::vector<int>& arr)
{
	int left = 0, right = arr.size() - 1;
	while (left < right)
	{
		int index_min = left, index_max = right;
		for (int i = left; i < right; i++)
		{
			if (arr[i] < arr[index_min]) index_min = i;
			if (arr[i] > arr[index_max]) index_max = i;
		}
		std::swap(arr[left], arr[index_min]);
		if (index_max == left)
			std::swap(arr[right], arr[index_min]);
		else std::swap(arr[right], arr[index_max]);
		left++;
		right--;
	}
}